/*
 * Licensed to the Tai Ping Jin Ke
 *
 * Copyright (c) 2022 .
 * All rights reserved.
 * 项目名称：呼叫中心-通用处理层-工作台
 * 版权说明：本软件属太平金融科技服务(上海)有限公司所有，在未获得太平金融科技服务(上海)有限公司正式授权情况下，任何企业和个人，不能获取、阅读、安装、传播本软件涉及的任何受知识产权保护的内容。
 */
package com.taiping.cc.platform.base;

import com.taiping.cc.platform.manager.transaction.PlatformServiceTransaction;
import com.taipingframework.boot.cache.core.CommonCacheHandler;
import com.taipingframework.boot.minio.ObjectStorageService;
import com.taipingframework.boot.session.core.CommonSessionHandler;
import com.taipingframework.utility.context.BeanLifecycle;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.concurrent.ExecutorService;

/**
 * 所有业务逻辑类的基类，
 * 为了消除引用DAO对象的重复编码，此处统一管理所有业务逻辑类对DAO引用
 */
public abstract class BaseService extends BeanLifecycle implements InitializingBean, DisposableBean {
    //region initMethod & destroyMethod - simple
    @Override
    protected void initMethod() {
        //something will be done at start up.
    }

    @Override
    protected void destroyMethod() {
        //something will be done at tear down.
    }
    //endregion

    //region InitializingBean & DisposableBean - simple
    @Override
    public void afterPropertiesSet() throws Exception {
        //something will be done at start up.
    }

    @Override
    public void destroy() throws Exception {
        //something will be done at tear down.
    }
    //endregion

    protected ObjectStorageService fileService;
    protected CommonCacheHandler cacheHandler;
    protected CommonSessionHandler sessionHandler;
    protected ExecutorService asyncExecutor;
    protected PlatformServiceTransaction platformServiceTransaction;

    @Autowired
    public void setFileService(ObjectStorageService fileService) {
        this.fileService = fileService;
    }

    @Autowired
    public void setCacheHandler(CommonCacheHandler cacheHandler) {
        this.cacheHandler = cacheHandler;
    }

    @Autowired
    public void setSessionHandler(CommonSessionHandler sessionHandler) {
        this.sessionHandler = sessionHandler;
    }

    @Autowired
    public void setAsyncExecutor(ExecutorService asyncExecutor) {
        this.asyncExecutor = asyncExecutor;
    }

    @Autowired
    public void setPlatformServiceTransaction(PlatformServiceTransaction platformServiceTransaction) {
        this.platformServiceTransaction = platformServiceTransaction;
    }

}
